package jc16;
/*练习方案二*/
public class jincheng2 {
    public static void main(String[] args) {
        myjic it = new myjic();
        Thread q = new Thread(it);
        Thread q1 = new Thread(it);
        Thread q2 = new Thread(it);
        Thread q3 = new Thread(it);
        Thread q4 = new Thread(it);
        q.start();
        q1.start();
        q2.start();
        q3.start();
        q4.start();

    }
}
class myjic implements Runnable{
    int a= 1;
    Object o = new Object();
    @Override
    public void run() {
        while (true){
            synchronized (o) {
                if (a <= 100) {
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(Thread.currentThread().getName() + "=" + a++);
                }
                if (a >100) break;
            }
        }
    }
}